#include<stdio.h>
#include<stdlib.h>

struct node
{
	int value;
	struct node *next;

};

void structPrint(struct node *temp)
{
	int i=1;
	while(temp != NULL)
	{
		printf("%d = %d\n",i,temp->value);
		temp = temp->next;
		i++;
	}	

}

void createStruct(struct node *temp, int size)
{
	struct node *nextNode;
	int value;

	for (int n=0; n<size; n++)
	{
		printf("enter value %d: ",n+1);
		scanf("%d",&value);
		
		if( n == 0)
		{
			temp->value = value;
			temp->next = NULL;
		}
		else
		{
			nextNode = (struct node*)malloc(sizeof(node));
			temp->next = nextNode;
			nextNode->next = NULL;		
			nextNode->value = value;
			temp = nextNode;
		}
	}


}


void main()
{
	struct node *head1, *head2,*head3; 
	struct node *currentNode;

	int value;
	int size;

	head1 = (struct node*)malloc(sizeof(node));
	head2 = (struct node*)malloc(sizeof(node));
	head3 = (struct node*)malloc(sizeof(node));
	

//node1
	printf("enter node1 size: ");
	scanf("%d",&size);
	createStruct(head1,size);

//node2
	printf("enter node2 size: ");
	scanf("%d",&size);
	createStruct(head2,size);
	
//node3
	printf("enter node3 size: ");
	scanf("%d",&size);
	createStruct(head3,size);
	

	//print


	currentNode = head1;
	while(currentNode->next != NULL)
	{
		currentNode = currentNode->next;
		if(currentNode->next == NULL)
		{
			currentNode->next = head2;
			while(currentNode->next != NULL)
			{
				currentNode = currentNode->next;
				if(currentNode->next == NULL)
				{
					currentNode->next = head3;
					break;
				}
			}
			break;
		}	
	}

	structPrint(head1);


		
}